<?php
	/**
	 * 自动引入类
	 * Enter description here ...
	 * @author ping
	 *
	 */
	class load
	{
		private static $folder = array(
			'module',
			'helper'
		);

		/**
		 * 自动载入方法
		 * Enter description here ...
		 * @param unknown_type $classname
		 */
		public static function autoload($classname)
		{
	        $class_list = self::get_class_list();

	        if (empty($class_list[$classname]) === FALSE)
	        {
	        	require_once $class_list[$classname];
	        	return;
	        }

	        foreach (self::$folder AS $v)
	        {
		        $file_path = self::get_class($v, $classname);

				if (file_exists($file_path))
				{
					require_once $file_path;
					return;
				}
	        }

			throw_exception::process(new Exception($classname . '没有找到', 2));
	    }

	    /**
	     * 获取类的路径
	     * Enter description here ...
	     * @param unknown_type $classname
	     */
	    private static function get_class($folder, $classname)
	    {
	    	return dirname(dirname(__FILE__))
				        . DIRECTORY_SEPARATOR
				        . $folder
				        . DIRECTORY_SEPARATOR
				        . str_replace('_', DIRECTORY_SEPARATOR, $classname)
				        . '.php';
	    }

	    /**
	     * 获取类的对应文件
	     * Enter description here ...
	     */
	    private static function get_class_list()
	    {
	    	return include dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'class.php';
	    }
	}